import React, { Component } from 'react';
import _ from 'lodash';
import Former, { validate } from '../../../components/Former';
import Button from '../../../components/Button';


export default class From extends Component {
  _validate = () => {
    validate((err, val) => {
      if (!err && _.isFunction(this.props.onSubmit)) {
        this.props.onSubmit(val);
      }
    });
  };
  render() {
    const fields = [
      {
        label: '',
        placeholder: '请输入短信模板',
        type: 'TextArea',
        key: 'content',
        initialValue: this.props.user.smsTemplate,
        rules: [{ require: true }]
      },
    ];
    return (
      <Former
        fields={fields}
        bottom={
          <Button
            onPress={this._validate}
            type="primary"
            title="更新短信模板"
          />
        }
      />
    );
  }
}
